package org.smr.ministore.micro.client;

import org.blade.utils.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.smr.ministore.entities.BrandOrgan;
import org.smr.ministore.entities.vo.BrandOrganQuery;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import feign.hystrix.FallbackFactory;


@Component
public class HystrixBrandOrganClientFactory implements FallbackFactory<FeignBrandOrganMicroServiceClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HystrixBrandOrganClientFactory.class);

    @Override
    public FeignBrandOrganMicroServiceClient create(Throwable cause) {
    HystrixBrandOrganClientFactory.LOGGER.info("fallback; reason was: {}", cause.getMessage());

        return new FeignBrandOrganMicroServiceClient() {

            @Override
            public int batchSave(List<BrandOrgan> entities) {
                return -1;
                }

            @Override
            public int batchModify(List<BrandOrgan> entities) {
                return -1;
                }

            @Override
            public int save(BrandOrgan entity) {
            return -1;
            }

            @Override
            public int updateById(BrandOrgan id) {
            return -1;
            }

            @Override
            public BrandOrgan queryById(Long id) {
                BrandOrgan brandOrgan = new BrandOrgan();
                brandOrgan.setId(-1L);
                return brandOrgan;
            }

            @Override
            public int deleteById(Long id) {
            return -1;
            }

            @Override
            public Pager<BrandOrgan> paginate(BrandOrgan entity, Long pageSize, Long pageNum) {
                Pager<BrandOrgan> pager = new Pager<BrandOrgan>();
                return pager;
            }

            @Override
            public BrandOrgan queryBy(BrandOrgan brandOrgan) {
                brandOrgan.setId(-1L);
                return brandOrgan;
            }

            @Override
            public List<BrandOrgan> queryAlreadyAssignedOrgans(BrandOrganQuery brandOrganQuery) {
                BrandOrgan brandOrgan = new BrandOrgan();
                brandOrgan.setId(-1L);
                return Arrays.asList(brandOrgan);
            }

        };//Return end
    }
}